home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / octa209s.zip / octave-2.09 / liboctave / dbleLU.cc < prev    next >
C/C++ Source or Header  |  1996-03-29  |  2KB  |  87 lines

  1. /*
  2.  
  3. Copyright (C) 1996 John W. Eaton
  4.  
  5. This file is part of Octave.
  6.  
  7. Octave is free software; you can redistribute it and/or modify it
  8. under the terms of the GNU General Public License as published by the
  9. Free Software Foundation; either version 2, or (at your option) any
  10. later version.
  11.  
  12. Octave is distributed in the hope that it will be useful, but WITHOUT
  13. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  15. for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with Octave; see the file COPYING.  If not, write to the Free
  19. Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  20.  
  21. */
  22.  
  23. #if defined (__GNUG__)
  24. #pragma implementation
  25. #endif
  26.  
  27. #ifdef HAVE_CONFIG_H
  28. #include <config.h>
  29. #endif
  30.  
  31. #include "dbleLU.h"
  32. #include "f77-fcn.h"
  33. #include "lo-error.h"
  34. #include "mx-inlines.cc"
  35.  
  36. // Instantiate the base LU class for the types we need.
  37.  
  38. #include <base-lu.h>
  39. #include <base-lu.cc>
  40.  
  41. template class base_lu <Matrix, double, Matrix, double>;
  42.  
  43. // Define the constructor for this particular derivation.
  44.  
  45. extern "C"
  46. {
  47.   int F77_FCN (dgesv, DGESV) (const int&, const int&, double*,
  48.                   const int&, int*, double&, const int&,
  49.                   int&);
  50. }
  51.  
  52. LU::LU (const Matrix& a)
  53. {
  54.   int a_nr = a.rows ();
  55.   int a_nc = a.cols ();
  56.  
  57.   if (a_nr == 0 || a_nc == 0 || a_nr != a_nc)
  58.     {
  59.       (*current_liboctave_error_handler) ("LU requires square matrix");
  60.       return;
  61.     }
  62.  
  63.   int n = a_nr;
  64.  
  65.   ipvt.resize (n);
  66.   int *pipvt = ipvt.fortran_vec ();
  67.  
  68.   a_fact = a;
  69.   double *tmp_data = a_fact.fortran_vec ();
  70.  
  71.   int info = 0;
  72.   double dummy = 0;
  73.  
  74.   F77_XFCN (dgesv, DGESV, (n, 0, tmp_data, n, pipvt, dummy, n, info));
  75.  
  76.   if (f77_exception_encountered)
  77.     (*current_liboctave_error_handler) ("unrecoverable error in dgesv");
  78.   else
  79.     ipvt -= 1;
  80. }
  81.  
  82. /*
  83. ;;; Local Variables: ***
  84. ;;; mode: C++ ***
  85. ;;; End: ***
  86. */
  87.